package cn.gson.crm.model.dao;

import cn.gson.crm.model.pojos.Employee;
import cn.gson.crm.model.pojos.SalesAt;
import cn.gson.crm.model.pojos.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface SalesAtDao extends CrudRepository<SalesAt,Integer> {
    //按照年查询销售目标
    @Query(nativeQuery = true,value = "select sum(SALES_VALUE) from SALES_AT where YG_ID=?1 and TO_CHAR(SALES_TIME,'yyyy') like ?2")
    public Integer selectSalesAt2(Employee employee,String salesAttime);
    //按照月份查询销售目标
    @Query(nativeQuery = true,value = "select sum(SALES_VALUE) from SALES_AT where YG_ID=?1 and  TO_CHAR(SALES_TIME,'mm') like?2")
    public Integer selectSalesAt4(Employee employee,String salesAttime);
    //按照日期查询销售目标
    @Query(nativeQuery = true,value = "select sum(SALES_VALUE) from SALES_AT where YG_ID=?1 and  TO_CHAR(SALES_TIME,'dd') like?2")
    public Integer selectSalesAt6(Employee employee,String salesAttime);
    //主页销售目标分布
    @Query(nativeQuery = true,value = "SELECT sum(SALES_VALUE) from SALES_AT where TO_CHAR(SALES_TIME,'yyyy-mm') like ?1")
    public Integer selectSaleszhu1(String nian);
    //主页销售目标分布2
    @Query(nativeQuery = true,value = "SELECT sum(SALES_VALUE) from SALES_AT where TO_CHAR(SALES_TIME,'yyyy') like ?1")
    public Integer selectSaleszhu3(String nian);
    //主页销售目标分布3
    @Query(nativeQuery = true,value = "SELECT sum(SALES_VALUE) from SALES_AT where TO_CHAR(SALES_TIME,'yyyy-mm') like ?1")
    public Integer selectSaleszhu4(String nian);

    //主页销售目标分布3
    @Query(nativeQuery = true,value = "SELECT sum(SALES_VALUE) from SALES_AT where TO_CHAR(SALES_TIME,'yyyy-mm-dd') like ?1")
    public Integer selectSaleszhu5(String nian);

}
